<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('未分配的资格证书列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <!--
                    <label>用户id：</label>
                    <input type="type" disabled th:value="${stuData.userId}">
                    -->
                    <label>当前学生id：</label>
                    <input type="type" disabled id="stuId" name="stuId"  th:value="${stuData.stuId}">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>证书名：</label>
                                <input type="text" name="cerName"/>
                            </li>
                            <li>
                                <label>发布机构：</label>
                                <input type="text" name="cerInstitution"/>
                            </li>
                            <li>
                                <label>证书获取时间：</label>
                                <input type="text" class="time-input" placeholder="请选择证书获取时间" name="cerGettime"/>
                            </li>
                            <li>
                                <label>指导老师：</label>
                                <input type="text" name="cerInstructor"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:certificate:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:certificate:remove')}]];
        var downloadFileFlag = [[${@permission.hasPermi('system:certificate:downloadFile')}]];
        var prefix = ctx + "system/studentData/authCertificate";

        $(function() {
            var options = {
		        url: prefix + "/unallocatedList",
		        queryParams: queryParams,
		        sortName: "cerId",
		        sortOrder: "desc",
		        showSearch: false,
		        showRefresh: false,
		        showToggle: false,
		        showColumns: false,
		        clickToSelect: true,
		        rememberSelected: true,
                columns: [{
                    checkbox: true
                },
                {
                    field: 'cerId',
                    title: '证书ID'
                },
                {
                    field: 'cerName',
                    title: '证书名'
                },
                {
                    field: 'cerGettime',
                    title: '证书获取时间'
                },
                {
                    field: 'cerInstructor',
                    title: '指导老师',
                    visible: false
                },
                {
                    field: 'remark',
                    title: '备注'
                },
                {
                    field: 'userId',
                    title: '所属账号id'
                },
                {
                    field: 'filePath',
                    title: '附件',
                    visible: false,
                    formatter: function(value, row, index) {
                        return $.table.imageView(value);
                    }
                }]
            };
            $.table.init(options);
        });

		function queryParams(params) {
			var search = $.table.queryParams(params);
			search.stuId = $("#stuId").val();
			return search;
		}

		/* 添加证书-选择证书-提交 */
		function submitHandler() {
			var rows = $.table.selectFirstColumns();
			if (rows.length == 0) {
       			$.modal.alertWarning("请至少选择一条记录");
       			return;
       		}
			var data = { "stuId": $("#stuId").val(), "cerIds": rows.join() };
			$.operate.save(prefix + "/selectAll", data);
		}
    </script>
</body>
</html>